﻿package tests;
import flash.events.Event;
import fpc.controls.buttons.Button;
import fpc.layouts.FlowLayout;
import fpc.layouts.HLayout;
import fpc.layouts.VLayout;
import fpc.containers.Container;

class DependenceTest extends GenericTest
{
	public function new() 
	{
		super();
	}
	
	var _container:Container<HLayout>;
	
	override function init()
	{
		_container = new Container<HLayout>();
		_container.addTo(this);
		var layout = _container.layout = new HLayout();
		layout.autoSize = false;
		
		var button = new Button('Button 0');
		layout.add(button);
		var button = new Button('Button 1');
		layout.add(button);
		
		var container = new Container<FlowLayout>();
		container.percentsWidth = 100;
		layout.add(container);
		var flow = new FlowLayout();
		flow.autoSize = true;
		container.layout = flow;
		
		var button = new Button('Flow 0');
		button.percentsWidth = 25;
		flow.add(button);
		var button = new Button('Flow 1');
		button.percentsWidth = 25;
		flow.add(button);
		var button = new Button('Flow 2');
		button.percentsWidth = 25;
		flow.add(button);
		var button = new Button('Flow 3');
		flow.add(button);
		var button = new Button('Flow 4');
		flow.add(button);
		
		var button = new Button('Flow 2');
		button.percentsWidth = 25;
		flow.add(button);
		var button = new Button('Flow 3');
		flow.add(button);
		var button = new Button('Flow 4');
		flow.add(button);
		var button = new Button('Flow 2');
		button.percentsWidth = 25;
		flow.add(button);
		var button = new Button('Flow 3');
		flow.add(button);
		var button = new Button('Flow 4');
		flow.add(button);
		var button = new Button('Flow 2');
		button.percentsWidth = 25;
		flow.add(button);
		var button = new Button('Flow 3');
		flow.add(button);
		var button = new Button('Flow 4');
		flow.add(button);
		var button = new Button('Flow 2');
		button.percentsWidth = 25;
		flow.add(button);
		var button = new Button('Flow 3');
		flow.add(button);
		var button = new Button('Flow 4');
		flow.add(button);
		var button = new Button('Flow 2');
		button.percentsWidth = 25;
		flow.add(button);
		var button = new Button('Flow 3');
		flow.add(button);
		var button = new Button('Flow 4');
		flow.add(button);
		button.height = 50;
		var button = new Button('Flow 2');
		button.percentsWidth = 25;
		flow.add(button);
		var button = new Button('Flow 3');
		flow.add(button);
		var button = new Button('Flow 4');
		flow.add(button);
		
		stage.addEventListener(Event.RESIZE, onStageResize);
		onStageResize();
	}
	
	override function resize(width, height)
	{
		_container.width = width;
		_container.height = height;
		
		var g = graphics;
		g.clear();
		if (_container.height > stage.stageHeight + .1)
		{
			g.clear();
			g.beginFill(0x7ef000);
			g.drawRect(0, 0, _container.width, _container.height);
			g.endFill();
		}
	}
}